package onehour.pulsar.examples;

import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.api.Schema;


public class OrderProducer {

    public static void main(String[] args) throws Exception {

        PulsarClient client = PulsarClient.builder()
                .serviceUrl("pulsar://localhost:6650")
                .build();

        Producer<String> producer = client.newProducer(Schema.STRING)
                .topic("my-order")
                .create();

        for (int i = 10000; i < 10020; i++) {
            System.out.println("send order id :" + i);
            producer.send(String.valueOf(i));
        }

        producer.close();
        client.close();
    }

}
